<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>MyTestEnvironmentUI</title>

<link rel="stylesheet" href="../../../main/css/style.css">
<link rel="stylesheet" href="../../../main/css/PilotCardUI.css">

<script src="../../../main/js/util/JavaScriptAugments.js"></script>
<script src="../../../main/js/util/Logger.js"></script>
<script src="../../../main/js/util/InputValidator.js"></script>
<script src="../../../main/js/util/ArrayUtilities.js"></script>

<script src="../../../main/js/Phase.js"></script>
<script src="../../../main/js/Team.js"></script>
<script src="../../../main/js/Maneuver.js"></script>
<script src="../../../main/js/ManeuverAction.js"></script>
<script src="../../../main/js/ShipAction.js"></script>
<script src="../../../main/js/Ship.js"></script>
<script src="../../../main/js/Path.js"></script>
<script src="../../../main/js/RangeRuler.js"></script>
<script src="../../../main/js/Weapon.js"></script>
<script src="../../../main/js/Pilot.js"></script>
<script src="../../../main/js/AttackDice.js"></script>
<script src="../../../main/js/DefenseDice.js"></script>
<script src="../../../main/js/PlanningAction.js"></script>
<script src="../../../main/js/CombatAction.js"></script>
<script src="../../../main/js/DamageCard.js"></script>
<script src="../../../main/js/UpgradeCard.js"></script>
<script src="../../../main/js/Token.js"></script>
<script src="../../../main/js/Position.js"></script>
<script src="../../../main/js/SquadBuilder.js"></script>
<script src="../../../main/js/Environment.js"></script>
<script src="../../../main/js/Adjudicator.js"></script>
<script src="../../../main/js/Engine.js"></script>
<script src="../../../main/js/SimpleAgent.js"></script>

<script src="../../../main/js/ui/ImageUtilities.js"></script>
<script src="../../../main/js/ui/HumanAgent.js"></script>
<script src="../../../main/js/ui/XWingPanel.js"></script>
<script src="../../../main/js/ui/PilotsUI.js"></script>
<script src="../../../main/js/ui/PilotCardUI.js"></script>
<script src="../../../main/js/ui/PlayAreaUI.js"></script>
<script src="../../../main/js/ui/PlayState.js"></script>
<script src="../../../main/js/ui/EnvironmentUI.js"></script>

</head>
<body>
	<audio id="tieFighterLaserAudio"
		src="../../../main/resources/audio/TIEFighterLaser.wav" preload="auto"></audio>
	<audio id="xWingLaserAudio" src="resources/audio/XWingLaser.wav"
		preload="auto"></audio>

	<div id='xWingPanel'>xWingPanel div</div>
	<table>
		<tr>
			<td id="imperialPilots" style="vertical-align: top">Imperial
				Pilots</td>

			<td id="playArea">
				<canvas id="playAreaCanvas" width="915" height="915"></canvas>
			</td>

			<td id="rebelPilots" style="vertical-align: top">Rebel Pilots</td>
		</tr>
	</table>
	<div id="messageArea"></div>

	<script>
        var LOGGER = new Logger();
        LOGGER.setTraceEnabled(false);

        var environment = Environment.createCoreSetEnvironment();
        var adjudicator = new Adjudicator();
        var mockEngine = {};
        mockEngine.addWinnerListener = function(listener)
        {};
        var imperialTokens = environment.getTokensForTeam(Team.IMPERIAL);
        var rebelTokens = environment.getTokensForTeam(Team.REBEL);
        var imperialToken0 = imperialTokens[0];
        var imperialToken1 = imperialTokens[1];
        var rebelToken = rebelTokens[0];

        var environmentUI = new EnvironmentUI(mockEngine, environment);
        environment.fireUpdateTrigger();

        // Move imperial token 0.
        {
            environment.setActiveToken(imperialToken0);
            var fromPosition = environment.getPositionFor(imperialToken0);
            var shipBase = imperialToken0.getShipBase();
            var maneuverAction = new ManeuverAction(environment,
                    Maneuver.STRAIGHT_1_STANDARD, fromPosition, shipBase);
            maneuverAction.doIt();
        }

        // Move imperial token 1.
        {
            environment.setActiveToken(imperialToken1);
            var fromPosition = environment.getPositionFor(imperialToken1);
            var shipBase = imperialToken1.getShipBase();
            var maneuverAction = new ManeuverAction(environment,
                    Maneuver.STRAIGHT_5_STANDARD, fromPosition, shipBase);
            maneuverAction.doIt();
        }

        // Move rebel token.
        {
            environment.setActiveToken(rebelToken);
            var fromPosition = environment.getPositionFor(rebelToken);
            var shipBase = rebelToken.getShipBase();
            var maneuverAction = new ManeuverAction(environment,
                    Maneuver.STRAIGHT_5_STANDARD, fromPosition, shipBase);
            maneuverAction.doIt();
        }

        // Move rebel token.
        {
            environment.setActiveToken(rebelToken);
            var fromPosition = environment.getPositionFor(rebelToken);
            var shipBase = rebelToken.getShipBase();
            var maneuverAction = new ManeuverAction(environment,
                    Maneuver.STRAIGHT_3_STANDARD, fromPosition, shipBase);
            maneuverAction.doIt();
        }

        environment.setPhase(Phase.ACTIVATION_END);

        environment.setPhase(Phase.COMBAT_START);

        // Rebel token fire upon imperial token 1.
        {
            environment.setActiveToken(rebelToken);
            var rebelPosition = environment.getPositionFor(rebelToken);
            var weapon = rebelToken.getPrimaryWeapon();
            var imperialPosition = environment.getPositionFor(imperialToken1);
            var combatAction = new CombatAction(environment, adjudicator,
                    rebelToken, rebelPosition, weapon, imperialToken1,
                    imperialPosition);
            combatAction.doIt();
        }

        // Imperial token 1 fire upon rebel token.
        {
            environment.setActiveToken(imperialToken1);
            var imperialPosition = environment.getPositionFor(imperialToken1);
            var weapon = imperialToken1.getPrimaryWeapon();
            var rebelPosition = environment.getPositionFor(rebelToken);
            var combatAction = new CombatAction(environment, adjudicator,
                    imperialToken1, imperialPosition, weapon, rebelToken,
                    rebelPosition);
            combatAction.doIt();
        }

        environment.setPhase(Phase.COMBAT_END);
    </script>
</body>
</html>
